import { PSControlObjectImpl } from '../pscontrol-object-impl';
import { IPSDEChartAxes } from './ipsdechart-axes';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';

export class PSDEChartAxesImpl extends PSControlObjectImpl implements IPSDEChartAxes {
  get axesPos(): 'left' | 'bottom' | 'right' | 'top' | 'radial' | 'angular' {
    return this.M.axesPos;
  }

  get axesType(): 'numeric' | 'time' | 'category' | 'log' {
    return this.M.axesType;
  }

  protected cappslanguageres: IPSLanguageRes | null = null;

  getCapPSLanguageRes(): IPSLanguageRes | null {
    if (this.cappslanguageres != null) return this.cappslanguageres;
    const value = this.M.getCapPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.cappslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getCapPSLanguageRes') as IPSLanguageRes;
    return this.cappslanguageres;
  }

  get capPSLanguageRes(): IPSLanguageRes | null {
    return this.getCapPSLanguageRes();
  }

  getCapPSLanguageResMust(): IPSLanguageRes {
    const value = this.getCapPSLanguageRes();
    if (value == null) {
      throw new Error('未指定标题语言资源');
    }
    return value;
  }

  get caption(): string {
    return this.M.caption;
  }

  get coordinateSystemIndex(): number {
    return this.M.coordinateSystemIndex;
  }

  get dataShowMode(): 0 | 1 | 2 | 3 {
    return this.M.dataShowMode != null ? this.M.dataShowMode : 0;
  }

  get maxValue(): number {
    return this.M.maxValue;
  }

  get minValue(): number {
    return this.M.minValue;
  }

  protected pssyspfplugin: IPSSysPFPlugin | null = null;

  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    if (this.pssyspfplugin != null) return this.pssyspfplugin;
    const value = this.M.getPSSysPFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyspfplugin = this.getPSModel4('res.IPSSysPFPlugin', value, 'getPSSysPFPlugin') as IPSSysPFPlugin;
    return this.pssyspfplugin;
  }

  get psSysPFPlugin(): IPSSysPFPlugin | null {
    return this.getPSSysPFPlugin();
  }

  getPSSysPFPluginMust(): IPSSysPFPlugin {
    const value = this.getPSSysPFPlugin();
    if (value == null) {
      throw new Error('未指定前端扩展插件');
    }
    return value;
  }

  get cls(): string {
    return 'PSDEChartAxesImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.chart.IPSDEChartAxes') return true;
    return super.instanceof(cls);
  }
}
